bugfix: categoricals were sometimes mis-encoded