Fixed a bug where the recent reference subquery fix was not always working.