Completely fix copy_r function.