Added a bunch of comments, and refactored code so that its more
managable