some bug fixes, update tests
again, major refactorin
more restructuring