#996: fix bugs picked up in review