Added some comments and did a wee bit of code cleanup.