Thread support added for parallel processing.