First refactoring and structure adjusting