I have copied the final piece of code into the collision kernel. Just need to make it work now.