Categorical variable bug fixes