Thermodynamics with Internal State Variables