Bug fixing in synchronization and permissions transfer protocol
Some refactoring.