Major rework migrated. Old version kept in separate branch
Migrated v2 code, part 2