Refatored code, added more support for locking of node mutex.
Refactoring of code; more locking of node mutex.