Fixed single-threading bug.