Threading implementation refactoring