Bug/inconsistent cookie management

Includes bug/overly-complex-certificate-verification-method, I rebased onto it.