It's important to check for NULL. Or it's going to get ugly here.

Same for the similar code above.