[#884] Fix logging statements and potential NPE