Popupmnu cleanup

*DO NOT MERGE*
This is my ongoing work to clean up `popupmnu.c`, ref #238
Adding as a pull so others more easily see there is work going on in that file.