Added checks for null branch pointers