fix lengths and delete nonexistant links