Refactor path serialization/deserialization to separate methods