Cookies' functions moved to main script, optimisation