Fixed some security issues as well as structure