Per Robot, altered "Replace the whole
!ent || ( ent.IsValid && !ent:IsValid() )
with
!IsValid( ent )"

Additionally, SafeRemoveEntityDelayed calls SafeRemoveEntity so ent:IsPlayer( ) isn't needed, but to prevent an extra timer from being created for an entity we won't remove anyway, I added that check.