Fixed NPE.
Merge pull request #1117 from slovdahl/master-slovdahl

Fixed NPE.