Cleanup duplicated methods.
Improve logging.
Correcting typos.
Adding a fix to deal with null.