One more suggestion! Sorry for posting two in one day, haha.
Currently, animals despawn in cave-level darkness (I understand why), but I think this should be disabled when the animal is inside a structure that is considered a "room" by [/debug rooms hi]=true (lights up green). I spent hours the other day trying to trap some piglets and finally got them in my covered closed pen with solid walls (after one unlucky lightning strike that killed all of my chickens in one go, I wasn't gonna take chances anymore), but totally forgot to put a light source in there. When I looked later, they were all gone, and a quick google search told me that the lack of light was probably the issue.
If there's a good reason why this adjustment shouldn't happen, I understand. Maybe it would throw a wrench in cave spawn rates, though I'm pretty sure most animals are only supposed to spawn on the surface, so none should be randomly spawning in like, tiny enclosed pockets of air underground. Hopefully?