Fixes to #163 and #165