Bug fixes for permission