(Hopefully) implemented double buffering.