Handle degenerate cases in batch histogram

Fixed problems when all bin counts were zero.