clean up & various bugfixes