Added support for threading