Minor refactorings
Added Permission check to metadata set