Further improvements of the buffer management code

Signed-off-by: Simon Busch <morphis@gravedo.de>