Copied the initial version from conkitty-route.