Collisions with edges still fishy. Ideas for improvements written in main file.