Optimize neighbourhood buildin.