Adjusted some log code and fixed a possible NPE.
Merge remote-tracking branch 'origin/master'