add persistent cookies and some fixes