Split code in multiple files

Split code in multiple files for easier maintenance