Add double buffering

Change the way rendering is done to facilitate double buffering