Moving shared helper code into its own class.