Added a lock to the rendering/updating code