Move generic code to 'util' module.