Fixed multithreading issues via dispatching to a

single thread.