Improve cookie handling