Put more cleanup code in ensure block