kind of fixed the threading. Still quite broken
Got reading and writing working

Tested only on a netbook, there might be something wrong with the queue usage.