Added threading support