Added multi-threading support.