bugfixes, style improvements