It's ok now. I'm thinking to write a function for creating internal extensions since many code might be duplicated.
@halton @gaochun @hmin