Clean up some loops