Fix brace formatting and clean up code.