Improved URI parsing