Document upload changes

Documents upload to the current selected category and includes some fixes and refactoring for permissions