Fix conventions and refactor code.