Added async support.
Fixed bugs with multi-threading, and improved data structure design.