First working and commented version of assignment.
Added clarifying comments.