Fixed some bugs in security stuff