new implementation of mode & modes

In his new implementation, the process of constructing count table & that finds the mode/maximum count is fused in the same loop.