Some minor code formatting and refactoring.