Added domain and multithreading support, fixed nt_malloc bug and updated docs