Added comments and fixed small bugs in Cnt... functions in alg.h