Minor reworkand bugfixes