made threads always daemon for simplicity. added wait() and stop() functions