add some helpful assertions
some refactoring in main class and kagreg