clean up buffer swapping logic
fix race condition in constraint tests