Fix a handle leak & change thread creation flag