More terrain tweaks, optimized code