latest update and cleaning of basic functions