added multithreaded support for host system, several other bugs fixed