Guard against null values causing Null Pointer errors.