Add refactoring for usage with threaded application