Small refactor and add getCookie()