Fix bug that lead to a NullPointerException.