More minor refactoring and removing of useless tests.
Refactor and document options.
Add some comments.