Fix undefined functions, replace with native functions