Migrated all code to use new data representation. Code is sometimes ugly, but it works.
Tests are not stable. Still to be fixed.