Move record threshold stuff into native, calling to Java where appropriate