Fixed a threading bug in gfx::Layer