Added some more native functions, fixed memory leaks