peel away local function definitions, replace empty letins by their value