Removing old cruft, part 1
Refactoring utiity functions
Broke everything. Temp commit.
Breaking things more