Changed node.c source - added some retval checking + moved threads_counter manipulation into a function