some representation changes and refactoring