Added some comments, removed some unnecessary code.
Added more comments to aid with understanding.