Fixed rare NullPointerException