Many improvements and added persistent cookie handling.