fix bug with ] after data_fields.  rename globals, etc.