Refactoring, more locking of node mutex, better handling of changed permission.

* Refactored code
* Mutexes of nodes are locked, when following commands are handled:
 - node_perm
 - node_owner
 - node_lock
 - node_lock
* Solved two TODOs:
 - When permissions of node are changed and client starts to be able to
   read node, then it receives command node_create of child nodes,
   taggroup_create commands of tag groups stored in node and layer_create
   commands of layers stored in node.
 - When node was locked by some client and user of this node lost
   permission to write to this node, then node is unlocked and
   coresponding command is sent to all subscribed clients.