Code cleaned, improved and corrected

All the examples from chapters 1-9 have been reviewed, checked that worked, optimised with basic controls to enhance the learning process and corrected when they didn't worked.