Minor refactoring of gui helper functions