implemented cache & permissions + lot of fixes

permissions still not working as I want