Optimized URL handling and hooks