Calc diff and terrain from file. Working version.