borrowing files from LexGen and measure magic