fixes massive go routine/memory leak, data race and early exit for timeout == 0