move xml infrastructure based cleanup steps to library