Fix multi-threading