Inverted some loops for less looping action.