Finish all the functions and Clean up code.