[refactoring] Refactor all replace type code.