Fix serialization of attached state

So the tree-view doesn't always show on reload.

Fixes #258