questions on kamma

I have read the sections in Ven Rahula's and Ven Narada's books on kamma as well as the class handouts. Most is very clear despite it being a complex topic.
However, there were 2 stories to illustrate kamma and its workings that were surprises to me. The first was that Ven. Mogallana was beaten some time after he attained arahantship. There was an explanation, presumably from the sutta commentaries, That he allowed this to happen for some reason.
This raises some problems. First, I am curious about the source of the story of the beating, and the source of the explanation. Some people say kamma cannot affect the person who has attained Nibbana, but then why did this happen to Ven Mogallana?
The second story is from the life of Lord Buddha himself. The class handouts and the reading from Ven Narada ( I think it was in his book, but can't find it now) is that Buddha suffered from constant headache. Was this a Jataka story of a previous life, or did the headaches occur in his lifetime as Gotama Buddha? Were the headaches before or after his enlightenment? Where is this story found? The commentary is that he suffered the headaches as a result of watching people fish. Where is the this explanation or commentary found?
These stories are most interesting and illustrative of cause and effect and I want to find out more about them.
Any help in tracing the sources of and clarifying these stories would be appreciated.
mark

Headaches, & death of Thera Maha Moggallana - Possible sources

I've found no specific reference to the Buddha's headaches, especially with regard to watching people fish. Several references simply mention that he suffered from "the ten adversities," the source of which seems to be Fo Shuo Xingchi Xing Sutra. See http://www.blpusa.com/download/bies04.pdf, for example.

Something a bit more specific with regard to the death of Maha Moggallana, from http://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=137
===========================
Dhammapada Verses 137, 138, 139 and 140
Maha Moggallanatthera Vatthu

Yo dandena adandesu
appadutthesu dussati
dasannarnannataram thanam
khippameva nigacchati.

Vedanam pharusam janim
sarirassa va bhedanam
garukam vapi abadham
cittakkhepam va papune.

Rajato va upasaggam
abbhakkhanam va darunam
parikkhayam va natinam
bhoganam va pabhanguram.

Atha vassa agarani
aggi dahati pavako
kayassa bheda duppanno
nirayam so papajjati.

Verse 137: He who does harm with weapons to those who are harmless and should not be harmed will soon come to any of these ten evil consequences:

Verses 138, 139 & 140: He will be subject to severe pain, or impoverishment, or injury to the body (i.e., loss of limbs), or serious illness (e.g., leprosy), or lunacy, or misfortunes following the wrath of the king, or wrongful and serious accusations, or loss of relatives, or destruction of wealth, or the burning down of his houses by fire or by lightning. After the dissolution of his body, the fool will be reborn in the plane of continuous suffering (niraya).

The Story of Thera Maha Moggallana

While residing at the Jetavana monastery, the Buddha uttered Verses (137), (138), (139) and (140) of this book, with reference to Thera Maha Moggallana.

Once, the Nigantha ascetics planned to kill Thera Maha Moggallana because they thought that by doing away with Thera Maha Moggallana the fame and fortune of the Buddha would also be diminished. So they hired some assassins to kill Thera Maha Moggallana who was staying at Kalasila near Rajagaha at that time. The assassins surrounded the monastery; but Thera Maha Moggallana, with his supernormal power, got away first through a key hole, and for the second time through the roof. Thus, they could not get hold of the Thera for two whole months. When the assassins again surrounded the monastery during the third month, Thera Maha Moggallana, recollecting that he had yet to pay for the evil deeds done by him during one of his past existences, did not exercise his supernormal power. So he was caught and the assassins beat him up until all his bones were utterly broken. After that, they left his body in a bush, thinking that he had passed away. But the Thera, through his jhanic power, revived himself and went to see the Buddha at the Jetavana monastery. When he informed the Buddha that he would soon realize parinibbana at Kalasila, near Rajagaha, the Buddha told him to go only after expounding the Dhamma to the congregation of bhikkhus, as that would be the last time they would see him. So, Thera Maha Moggallana expounded the Dhamma and left after paying obeisance seven times to the Buddha.

The news of the passing away of Thera Maha Moggallana at the hands of assassins spread like wild fire. King Ajatasattu ordered his men to investigate and get hold of the culprits. The assassins were caught and they were burnt to death. The bhikkhus felt very sorrowful over the death of Thera Maha Moggallana, and could not understand why such a personage like Thera Maha Moggallana should die at the hands of assassins. To them the Buddha said, "Bhikkhus! Considering that Moggallana had lived a noble life in this existence, he should not have met with such a death. But in one of his past existences, he had done a great wrong to his own parents, who were both blind. In the beginning, he was a very dutiful son, but after his marriage, his wife began to make trouble and she suggested that he should get rid of his parents. He took his blind parents in a cart into a forest, and there he killed them by beating them and making them believe that it was some thief who was beating them. For that evil deed he suffered in niraya for a long time; and in this existence, his last, he has died at the hands of assassins. Indeed, by doing wrong to those who should not be wronged, one is sure to suffer for it."
===========================
I do not consider this a definitive reference. The author attributes the stories to Buddhaghosa's Dhammapada Commentary from the fifth century BC, and you might want to research that. No "deeper" reference is offered by the author at the link cited. One might also wonder at Buddhaghosa's source for the story. If orally transmitted, then how reliably?

Regardless I thought these things might be of interest to you.

Ken