fix bufferSize computation. Thanks @crossle