You are right, Madara took over after he got rid of Pain and Itachi. Madara manipulated everything from the Shadows lol, out smarted Itachi and played along with Nagato and semi-used him.If pain was trying to kill naruto he would be dead now and he was weak from facing konoha
lol well you could be right or more likely they made a deal i think it was mentioned in the manga actually about just destroying the uchiha anyway Itachi admitted he was used by Tobi to some extent Nagato also however Pain was the officila leader of the akatsaki and had his own plans if they didnt fit together im sure Nagato would of had no use for him think about it out of the relationship who had more to gain from the other Tobi thats why he suggested to pain go to konoha and capture the nine tails this is how kishi made it Tobi never ordered him he always suggested things just like the weasel he is
Yahiko created the akatsuki under Madara's influence, so in a way the rightful leader of Akatsuki from the start was Madara Uchiha.