Fixes error when creating or loading threads