Trial merge of PR 11 with the whitespace-only changes omitted.

This PR is a copy of PR#11 which has has been merged with --squash and had the whitespace-only changes filtered out with `git diff -w | git apply --cached --ignore-whitespace`.  Note that this reduced the size of the combined patch file from ~66000 lines to ~3600 lines.

@Metallicow please review this and see if all of your real changes made it through the filter okay.