Stumbled into these while debugging a Papyrus error Pete reported for Forgotten Seasons, but since this is a Dawnguard script I figured we should probably include the fixes here. The issues are as follows:
1. There's a race condition that can result in a "no 3D" papyrus error despite the checks to ensure everything is loaded. This happens when the player leaves the cell while the script's HandleLightning function was in its wait block. GetNthLinkedRef(CurrentCastPoint).Is3dLoaded() will succeed as the Xmarker hasn't yet been unloaded, but it will have been unloaded between the check and the time the lightning attempts to fire. Adding OnCellDetach logic to immediately unregister (while avoiding a wait loop) prevents this race condition.
2. This one is a little silly, not sure how none of us caught it until now. Both CloseSoundinstanceID and FarSoundinstanceID are defined as CloseImpactSound.play(GetNthLinkedRef(CurrentCastPoint)). FarSoundinstanceID is pretty clearly supposed to use DistantImpactSound, not CloseImpactSound.