What allowed the ruling elite to maintain power during the Mamluk period