Encode string before write
Resolve references before creating a list