Added mutex guards for popping from queues.