Attempt at fixing an NPE, take two.