Modify the codes to run in RT4

Hi

This extension didn't work for RT4, so I had made some changes
to make it work.

Hope you can pull the changes into your repo.

Thanks.

Regards
Hao