Fixed a bug with recursive refs