move functions into RT::Handle from upgrade script