Finished all the extra code and added comments throughout.