Initial commit of the async version

Not fully working yet. Some features missing, not tested.
A lot of things were changed, mainly the threads and generators were
changed to coroutines, but the old interface was kept to be backwards
compatible.