Some fixes for category sorting