Modify the encode to subroutine index and  remote type