Patch 2

Commits involve fixes for issues: #18, #21 (partial)

Commits also involve some extra changes, see commit messages.