Finished up grouping.

Code needs to be refactored badly.