a lot of bugfixing