clean up code
change api, add gc, bug always segmentfault