The itemtooriginalpoketable has an entry for every item, being the dex number of the 'mon it affects. Itemtonewpoketable is the same, but tells the routine what index the item should give to the 'mon if the dex number from the first table matched. As for the dex restore or whatever, I believe that one's unfinished and I used the other routine, having special clauses for Arceus and Gira.