threaded code, mostly done, still doesn't compile