Little refactoring and added missing imports