Replaced unit and type with parameters taken from the XML file.