Cleaning up before commiting final result