Refactor library class
Add thread_safe as a dependency