Why does changes not get saved in $form, or what is overiding it?

i would like to set custom class to multiple fieldset's in ajax callback function:

    if (something){
      $form['fieldset_01']['#attributes'] = array('class' => array('custom_class'));
      $form['fieldset_02']['#attributes'] = array('class' => array('custom_class'));
    }else if (somethingelse)
      $form['fieldset_11']['#attributes'] = array('class' => array('custom_class'));
      $form['fieldset_12']['#attributes'] = array('class' => array('custom_class'));
} etc...
return $form;

When $form is returned, the element that i have set in this call in rendered fine, with new class but the element's that i have rendered in previous calls have lost this new class. Like they were rendered with default values.

Thanks!