fixing undefined functions and null pointers