Use native functions; fix #1612; fix #1348