Refactored a ton of functions so we can easily generate other

group tables.