Improvement to cookie handling