Minor improvements to popup functions