Optimize and fix some bugs.

1. use the KSC memory layout to avoid conversion.
2. some minor bug fixing for KSC.
3. improvement for KRT TracingInstance class usage.