Bug fixes in buffer manager