Refactor Threadpool class

Part of #4 issue.
No newline at the end of file. Check other files as well.