Fixed the collision issue (it was an off-by-one in the code that steps through the lines of the polygon, fixed by explicitly checking for that and using the first vertex).