Allocate memory in larger chunks, bsearch when possible