Added security checks, and some other fixes.
Merge branch 'develop'