First working version of the assignment. Parts 1 and 2 done.