fix
Refactor code a bit
Add thread safe queue and thread pool