fixed app references to lib views
revise permissions checking.
add parameter comments and checks, generalize permissions