native: add some functions and fix some bugs