Restore instance state in correct order

Fixes issue 5968