Merge pull request #1198 from dorkster/fixes

Segfault fixes