Cleanup buffer code.