Reworked integration to better handle multi-threading