Fixes #129 and #158