Refactoring for the second part of the tutorial + split in 2 files.