rewrite collect pass, fixes a bug that made :constants leak from inner fn to outer