fix a couple of bugs reported by Amund