Changed pointer null checks to use != NULL