Cleaning and refactoring

Code is cleaner with more comments and less bad code