Improve initialize and cookie based auth