changed principal metadata updating in single external function, cleand ...

...up some api doc