Replaced cleanup() with python's 'with'.