This commit fixes issue #527 and move the bsearch function to a native C-code. This change improves the performance of this function.