restructure buffer init