Huge refactoring for v2