Fixes #1013 NullPointerException