STSADM export / import fails because of "ghost" event handlers

It's not uncommon at all to encounter the following scenario:
A SPS 2003 environment on which you had custom event handlers registered was migrated to MOSS 2007. Now you try to export / import some sites, and get an error message similar to the following:

 Could not load file or assembly DocLibHandler, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bba06fba3a7c7829 or one of its dependencies. The system cannot find the file specified.

Of course, the event handlers were not deployed as solutions, but rather attached manually. So how to clean them up? Here's what we did:

 SPFarm farm = SPFarm.Local;
SPWebService service = farm.Services.GetValue<SPWebService>("");
foreach (SPWebApplication webApp in service.WebApplications) {
  foreach (SPSite site in webApp.Sites) {
    foreach (SPWeb web in site.AllWebs) {
      foreach (SPList list in web.Lists) {
        if (list.EventSinkAssembly == "DocLibHandler, Version=1.1.0.0, Culture=Neutral, PublicKeyToken=bba06fba3a7c7829") {
          list.EventSinkAssembly = String.Empty;
          list.EventSinkClass = String.Empty;
          list.EventSinkData = String.Empty;
          try {
            list.Update();
          }
          catch (Exception e) {
            Console.WriteLine(e.ToString());
          } } }
      web.Dispose();
    }
    site.Dispose();
  } }

It's not nice, but it works ...