Completely re-written terrain detection logic.
Now uses correct sensor lines. Sensor lines can be re-used elsewhere.
Missing files from last commit... oops