rex_select: improved optgroup handling, closes #145