Refactor sniffer based on @ebolyen's comments

Much shorter and cleaner now!