fixed leakage of threads
added docs