integrate with terrain properly, and mock it out in tests