Issue #8 implemented.
Minor cosmetics and refactoring.