bugfixes & cleanup