Fixes for issue #169 and #170