Refactor.
Add missing buffer swap.