Latests improvements.

The script is ready to be used and merged. 

Thank you for your patience/help.