Import Cilph's refactoring work