Fixed a bug with the new ref structure