Use atomic pointer swapping for swapping frames

I can't help but wonder if this is causing some issues with frame
duplication, I suddenly realized the code wasn't particularly thread
safe so I threw this in as a precaution.