Fixed some bugs in cookie system