Refactored code.  Minor bugfixes.

Started adding support for parameter parsing.