Refactor Threadpool class

Part of #4 issue.
OK, I'll do the ticket if it's not already done.