A lot of housekeeping in the code.
Fixed issue #3.
Implemented #7 and #11.