bugfixes, cleanups