Improved handling of a rare NullPointerException