Document gen-related functions, add ungroup-gens, cleanup group-gens