Calculate full urls once; refactor code.