Db interaction. Contains fixes.

This commit fixes db interaction granting/revoking user permissions and separates internal areas from public areas.