Added lock around deque