Heat treatment of titanium and titanium alloys