Improved the way API URLs are constructed