offloaded buffer swapping to scripts