ported part of the binary check over from JS.  This is slow.