Added code to handle draining.