Split gallery into categories.