Vulnerabilities corrections (2)

I have updated this pull request. I suppose that it should now merge clean...
This pull request consists of several minor changes - minor error corrections and code cleaning.