Tentative fix for NPE crash on 4.0.x and below

Closes #105 (maybe).