Refactoring and locking of node mutexes.

Refactoring of code (better returns of functions).
Nodes are locked in vs_node.c.