Potential crash fix

This might fix issue #333, description is too vague to tell.