Altered to use JD's new collision algorithm.