Extracting common files and refactoring