Codestyle changes and bugfixes