Fixes for thermostat, mostly related to NH-chains.

Change-Id: I9bbc6dde9f48c54eb1091264dfb5c3518182a7ff