Staying alive. Fixes #166. Plus other stuff.