Add code, comments and cleanup for assignment 2.