Cleanup some loops