Clean up code and update functions.