bug fixes
change permissions functions
minor fixes