Fixes from last night that I forgot to commit. Mostly minor refactoring/reformatting