Buffer: add arguments to write and release events
Buffer: code cleanup