Move terrain code into a class