moved rename_variables before discarding unwanted columns, for consistency with other functions
rename_variables now makes assertion names valid field names; occurrences now applies this