Refactoring of `core.FunctionalGroup` and `core.LeavingGroup`.

* Introduced a new `core.AbstractGroup` as the base class for the
  above two classes.