add a usable xim, prove-of-concept on addon function call
fix some memory leak.