Make some final refactoring