Apply suggested changes: move logging outside of mutex, fix comments, fix squash.