Added uri sniffing and corrected some code fragments.