Imported from https://github.com/dswatson/cpi