Added threading support.