nodestate can be NULL when node is no longer connected,
leading to a segmentation fault (refer T64).
Added assertions to other places where node state was
obtained and later used without checking if non-null.
Depends D325 (using nullptr) so that the diff of this change covers only the relevant modifications