Tidied up the node-controller code

Brought it more into line with the way the agent-controller and controlserver-comms scripts work, making the code a little easier to understand.