Reworked some parts of the collision detection mechanism. Not finished,
but works.