Clean up, redo cookies, make somewhat more idiomatic