Added some threading stuff. Doesn't work, but structure is there.