Fixed multi-threading problem