Rearranged some things, refactored and fixed constants