Added check and test for null pointer, and 1 TODO