Ref refactoring