bugfixing (now all test pass) + performance improvements
cleanup