Bugfixes, style improvements