Fix nil references which should have been undef