Refactoring intermediate generator for clarity