Rearrange where the popup menu stuff is created