#691 - Protected against NPE
(cherry picked from commit 200c2cf)