Added checks for null branch pointers
Merge pull request #903 from lodle/crashfixes4

Added checks for null branch pointers