add some buffer management