Better calculation of root url (which we need for the presence info)