Clean up code and get rid of unused functions.