cleanups and bugfixes