fix sigsegv

And one illogical path