Fixing the boundary collisions.