Refactoring code using non-borrowing versions.