Cleaning up code

Edited by Skimdog

polished comments, changed few variable names, and other trivial details