Smarter url handling