Hotfix/issue #170 rebased

Handles #170 and #240 with minor cleanups