Updated to avoid friendly fire, optimize collision detection.