Cleaning up code and style