Fixed permission checks
Fixed logout