Format and clean up code