Fix a couple of races

Fixes #16