Fixed some bugs in cookie handling on the client side, and other misc bugs.