Cleanups

Several changes, in preparation for release.
@keithw  would be great if you could take a look at these, specifically issue 40, which I think is useful to debug crashes in the wild.