Split code in multiple files.
Large refactoring. Sort of cleaner.