[LIR] General refactor to improve compile-time and simplify code.