Added some new comments and tweaked some code