bugfixes/refactoring