Implement double buffering

This is a cleaned-up version of some of our internal diagrams hackery. This code is untested, but our hacked version worked pretty well.

I'm still pretty new to Haskell so please feel free to clean up all of the code smells :)