Ghosting of Page Layout or Publishing Page

Sometimes we have a scenario where we need to ghost or uncustomize the page, 
Following is the code for the same,

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(sSiteURL))
{
PublishingSite publishingSite = new PublishingSite(site);
PageLayoutCollection pageCollection = publishingSite.PageLayouts;
foreach (PageLayout layout in pageCollection)
{
SPFile currentFile = site.RootWeb.GetFile(layout.ServerRelativeUrl);
if (currentFile.CustomizedPageStatus == SPCustomizedPageStatus.Customized || currentFile.CustomizedPageStatus == SPCustomizedPageStatus.None)
{
try
{
currentFile.RevertContentStream();
currentFile.Versions.DeleteAll();
currentFile.Update();
site.RootWeb.Update();
}
catch (Exception ex)
{
}
}
}
}
});
Download Source Code