Some formatting and refactorings