Clean formatting and refactor