Now works threaded.  Some issues still to resolve though.