Issue 339 fixes

Includes code for:

* fixes #335
* fixes #339