refactoring/bugfixes