bugfixes and style fixes