many fixes/ refactorings