Added threading support and scripting