Added better serialization for terrain ids.