Tests for collision detection and a removal of some redundancy from the algorithm