Integrated with Frei's changes last integ