By the way, you dont need to create a local for frames you create with CreateFrame if these frames have a name. The name will be used to create a global named like the frame.
Code:
CreateFrame("Frame", "MyFrame")
MyFrame:Show()
Looking at your code, this could save insane amounts of upvalues...