Added ability to specify callbacks for calculation total number of items and for items slicing