Refactoring; Minor code cleanup
Store buffers into WBufferState object
Added a class for _buffer_opened