refine & fix bugs for sdk