Replace horrendously-unreadable vision code.

Some of this should go in a coord-handling file.