More work on grouping patterns, fixed up JSON section.