additional tweaks for reusing buffer, shrink size