Improve/fix buffer handling
Fix locking around close events
Improve log message consistency