fix writability callback
trim buffers before recycling
Merge remote-tracking branch: upstream/master