added null checks for leaf and phrase matcher
Merge remote-tracking branch 'origin/dook' into marit