A bunch of miscellaneous updates/cleanup/refactoring