Cookie handling performance improvement

This still needs testing and review. It worked on the crawl I tested it with, but quite possibly has broken or changed something with cookie handling.