Set nonextant references to NULL. Fix #587.