refactoring of cookies handling: no longer is object, just functions
simplified factory method