#119: implement some feedback from #996.
#996: fix bugs picked up in review
Merge pull request #1015 from benfitzpatrick/996.feedback-other

#119: implement some feedback from #996.