Added option records

to define groups and labels. Also removed some duplicated
code.