Fix for setting and returning ref.