more buffer bug fixes