Fix of imports and basic refactoring