Fix a compile error
Improvements to popupmenus, fix #245 and #246