Only things I can point out:

1.) There's an alive flag on each entity you should check instead as it checks much more than health to assure validity.
2.) TEAM_FREE == 0 but you should make sure it's not a FFA match first.