More crash prevention. Fixes #12.