Fixed some bugs and permissions