Clean up some code and add all functionality.