fix permissions issues with sharing
refactor and fix issues with user search