Better truncation

URLs are now truncated from the end instead of the middle, and any trailing slashes are removed.