Fixed a bunch of crashes reported to openeye.