Merge pull request #1613 from marcel-blonk/PLFM-3108

generate as clauses only where needed