Reorganizes some code for future features and changes.