Formatting and cleaning up some code