Changed the synchronous queue to a threadsafe deque, and removed a mutex
Fixed some syntax errors etc