Restore categorical variables and misc bugfixes in

data processing steps