Removed a few unused variables, added some comments.
Added some comments, removed some unused variables.
Various minor changes.