Fixes for issue #24

Proposed resolution for (most of) the problems in issue #24.  The remaining two errors are real errors to be solved by #23.