Fixed some issues with permissions not working correctly.