Fixes the handling of multiple with statements/CTEs