Major internal rewrite

Make parser, commands and groups conceptually consistent.
This introduces small API breakage, but only on API that is
rarely used. This also privatizes some of the previously
public fields and functions that were not supposed to be public.