--- mythburn.py.orig	2007-07-04 13:01:08.000000000 -0700
+++ mythburn.py	2007-07-20 00:11:26.000000000 -0700
@@ -1759,6 +1759,7 @@
         #Number of video items on this menu page
         itemsonthispage=0
 
+        endbuttons = []
         #Loop through all the items on this menu page
         while itemnum <= numberofitems and itemsonthispage < itemsperpage:
             menuitem=menuitems[ itemsonthispage ]
@@ -1927,8 +1928,7 @@
                         button=dvddom.createElement("button")
                         button.setAttribute("name","previous")
                         button.appendChild(dvddom.createTextNode("{g2=1;jump menu %s;}" % page ))
-                        menupgc.appendChild(button)
-                        del button
+                        endbuttons.append(button)
 
 
                 elif node.nodeName=="next":
@@ -1936,8 +1936,7 @@
                         button=dvddom.createElement("button")
                         button.setAttribute("name","next")
                         button.appendChild(dvddom.createTextNode("{g2=1;jump menu %s;}" % (page + 2)))
-                        menupgc.appendChild(button)
-                        del button
+                        endbuttons.append(button)
 
             #On to the next item
             itemnum+=1
@@ -1945,6 +1944,10 @@
         #Move on to the next page
         page+=1
 
+        for button in endbuttons:
+            menupgc.appendChild(button)
+            del button
+
     if wantIntro:
         #Menu creation is finished so we know how many pages were created
         #add to to jump to the correct one automatically
