Thousands of trapped miners rescued in South Africa