Fix two bugs about insufficient and premature cleaning.
Making PEP8 happy.