export flatten/unflatten; strengthen isOfType
Update try with resources