fixes + refactoring