Fix for categories. Replaced db.indexes with db.metadata