many bugfixes and small improvements