Added extra permission checks
Fixed default value for debug mode
