Add comments, remove not needed code and improve file structure