Minor Bugfixes and code layout corrections