Please give me reference of the hadith which says that in the days of the Prophet (sws), women were initially stopped from visiting the graves because they used to vociferously wail. Once the women had learned to restrain themselves at such places, they were allowed to visit the graveyards.
The following discussion from Fiqhus Sunnah of Syed Sabiq covers the entire material you need:
Imam Malik and some Hanafi scholars, and, according to one report from Ahmad, most of the scholars hold it permissible for women to visit graves. This is based on the following hadith from 'Aishah, "What should I say to them, O Messenger of Allah when visiting graves?" As mentioned above Abdullah Ibn Abi Mulaykah is also reported to have said, "Once 'Aishah returned after visiting the graveyard. I asked, 'O Mother of the Believers, where have you been?' She said: 'I went out to visit the grave of my brother Abd ar-Rahman.' I asked her: 'Didn't the Messenger of Allah, peace be upon him, prohibit visiting graves?' She said, 'Yes, he did forbid visiting graves during the early days, but later on he ordered us to visit them'." This is reported by Al-Hakim and Al- Baihaqi, who also remarked that this hadith was narrated only by Bistam bin Muslim al-Basri. Dhahabi said that it is a sound hadith.
Anas reported: "The Prophet, peace be upon him, saw a woman crying by the grave of her son, and said to her, 'Fear Allah, and be patient.' She replied, 'What do you care about my tragedy?' When he went away, someone told her, 'Indeed, that was the Messenger of Allah, peace be upon him. ' The woman felt extremely sorry and she immediately went to the Prophet's house, where she did not find any guards. She called out: 'O Messenger of Allah! I did not recognize you.' The Prophet, peace be upon him, said, 'Verily patience is needed at the time of the first affiction'.'' (Bukhari and Muslim) This supports the argument in favor of the permissibility of women visiting graves, for the Prophet, peace be upon him, saw her at the grave and did not show his disapproval of it.