Fixed at least 3 crucial bugs in core and dumper.
Tests work, but trans_by_grids fails for some test grids.
Large code cleanups.