Moved ESM up into main module, working (old and a new unit test both pass) and minor changes like wide_merge added.