Clean up code and make it work.