Majur refactoring; Equational reasoning is starting to work
minor changes