Fixed several bugs in buffer fcns