Improved vector's serialization logic.