Fix thread handle copying