v2.0: a lot of refactoring