Guard against null pointers and remove unnecessary include.