A bunch of cleanup and reorganization