Reorders functions some cleanup