cookie support and regexp cleanup

See https://rt.cpan.org/Ticket/Display.html?id=83468 for details.