Fixes (hopefully) for issue #165