Fixing race conditions with lib loading