Fixes #20

Fixes #20.

Branched after the completion of issue 18.  Also includes the work from issue 16 manually patched in.