Fixed threading bug in graphics