Further improvements to collisions

Made wall collisions more robust.