Thermodynamics of stable and metastable phases in the NiTi system and its application to amorphous phase formation