Refactor globals and organize

Edit -> Code Folding -> Fold All doesn't look terrible anymore