Cleaning up homework 1 & 2

The code was revised in accordance with the comments.