Added some secure checking and some code polishing
Merge remote-tracking branch 'origin/master'