Fixes which prevent segv we were seeing