Final cleanup

I went back through the program a few more times and changed the
following.

* Updated variable names to be more descriptive. This lead to a couple
of cleaner pieces of code
* Moved some parameters so that their values are obtained in the
function giving a cleaner interface
* removed some redundant code