Null pointer fix and logs for testing