new functions and many bugfixes