Implemented double buffering.