Refactoring and reformatting