Mulltiple bugfixes and small improvements