Buildings represent a significant share of global energy consumption in the European Union (EU). Heating and domestic hot water (DHW) needs account for an important part of that energy use. Considerable energy savings can be achieved by retrofitting buildings and improving heating systems. Such improvements are covered in this paper, as it presents a comprehensive retrofitting of 31 large residential buildings, within the European funded project CITyFiED. The retrofitting process consists of various measures (new renewable energy generation systems, facade retrofitting, etc.), but the focus of this paper is on district heating (DH) optimization measures, with the aim of increasing its overall system efficiency and sustainability. To that end, the actual system is modeled in a dynamic modeling software, TRNSYS, and modifications are tested. The results are a series of improvements that lead to better system performance, higher efficiency and sustainability.