tlg, phi7 compile refactored