fix some bugs in category and agency statefulness