Fix bug in ReverseNodesInKGroup, add some comments