Fixes for issues 153 and 154

See issues for descriptions of what these commits fix.