Fixed some terrain code concerning heightmaps.