incorporated most of the corrections made by Nicolas Le Novere (lenov)