terrain optimization, fix some bugs