bugfixes and formatting