Fix bug in terrain generation