Changes to the article, removed some redundant code and added some more comments.