Fixed #60 (common base class for group, primitive), some cleanups