Added more debug statements, and returns NULL if argument was NULL