Changes to allow multi-threading (if supported).