Fix off-by-one in distance table plugin.

Should fix #1320.