Some more fixes as per David's peer reviews.

To be squashed into the previous commit