Added getRef function to extract Int from a Ref.