Only what still does not work is selecting last selected node.
Please clarify what exactly doesn't work?

Does GetState save a correct internalId?

Does the StateRestore try to select the node? What happens in the StateRestore handler?

Are you sure to rely on a Node's internalId if no Node's ID is set up? I guess an internalId is auto-generated and it might change and the StateRestore won't find a correct Node.