DynamicNodes are passed properly when unloading state. Code cleanup