Added permission support.
Small fixes.