Annndd I'm an idiot. After looking at it with a clear brain the problem was between the screen and the chair. Basically I managed to forget how I was calling the function. My theory was I was calling the function per menu item, when really I was passing in an array of menuitems then adding submenu items per menu item (deep breath). Sorry for the hassle, and thanks for making my brain click :)