fix links and remove trailing spaces