UPDATE: more code cleaning and consistency updates