Fixed line endings
added caching for route length - maybe not needed