clean up and bugfixes