Improved URI generation