This code needs to be moved to a common header / source file. We have multiple instances of this code now.