Adding more patches to the master branch

I have pushed some more patches to the master branch (that is the branch that contains patches that will feature in the next release). These patches improve code robustness and make sure we follow more stricly the provisions of GPL.