Importing category optimization code from h2gglobe