Minor reformatting and refactoring