Fixes PR #168 and #167