Fix bugs, improve locate performance.