Added a catch for an NPE that sometimes occurs.