A few tweaks to naming, and extraction of functions to constants.