Refactor terrain model.