Miscellaneous code reformatting/refactoring