UP-3702 Fix comparison bug
UP-3704 : Added null check to a loop when collecting grouping
information.