Fix NullPointerException. Fixes #147