bugfixes, cleanup