Updated mainly the varD1D and hamiltonP functions