In certain conditions closestSideFromInside would fail.

That would be because an iterator would try to be incremented. If the
iterator is invalid, the increment will deference the iterator and raise
a segmentation fault.
Added wall collisions.