finished threading, minor fixes