added debug, modified threadpool