Merge pull request #1335 from nevkontakte/gng7 Final round of refactoring ported from the original generics branch.