Add qthreads implementation, minor cleanup.