many bugfixes, thnx to clang