Most of the logic in `writePod()` and `writeExternalPod()` are shared, there might be opportunities to refactor the code to reduce duplication.