lot's of small bugfixes and code style fixes