Clean up some of the code