Cleaned up some loops