Fix urls, make related code a bit more readable.