I found this site that apparently solves much of the problem. Basically it says:
1- It is necessary to make distinctions between extraction torture and punitive torture, between torture itself and the procedures and restrictions that safeguard torture, and between torture that does not destroy bodily integrity and torture that destroys it.
Saint Thomas Aquinas had taught that the state had “perfect coercive power”. Therefore, the execution of a just sentence by the state for a serious crime was the only time Aquinas agreed that bodily integrity could be destroyed by “death and mutilation”. In examining confession-extracting torture, he appears to have agreed with Pope Innocent IV that ensuring the individual’s survival and bodily integrity were the limits of what was allowed in this type of torture; this is not due to the inherent dignity of the person, but because in the extraction torture often the fault of one of the parties has not yet been determined.
Punitive torture, on the other hand, is a totally different story. Here the guilt was established, and the state, by virtue of its “perfect coercive power”, is even capable of exceeding these limits established when it comes to punishing. Consequently, the state had the authority not only to sentence men to death, but also to inflict “irreparable” punishments that minor than death, such as mutilation, cutting off members, flogging, etc.
2- Isn’t Pope Innocent IV in total contradiction with Pope St. Nicholas I? Not if we understand the arguments correctly. The first Christian millennium, exemplified by Nicholas I, said that “Torturing to extract information is ineffective and, therefore, an abuse of justice”, to which the second Christian millennium, exemplified by Innocent IV, replied that “UNLESS its application is protected by appropriate guidelines”. It was a legitimate development of teaching based on the legal developments of the canonist movement in the 12th and 13th centuries.
Note that, from a moral point of view, this development in teaching would not have been possible if the original arguments against torture were based on the dignity of the human person, but as Saint Augustine and Saint Nicholas I’s arguments against torture were based on the inefficiency of the method, it left room for developments in teaching: if torture could produce reliable results, it would be fair and therefore permissible. Again, although the first millennium condemned the use of torture, they did not recognize any fundamental human right not to be tortured and, therefore, the development represented by the papal bull Ad Extirpanda was possible.