Use "base" as the cookie name. Minor tidy and refactoring of code, and cookie handling