many changes and bugfixes