Fixed multi-threading problems.