Improvement on permission management.
Other fixes.