Trying to fix weird multi-threading issue