amalgamation

The code for amalgamation is here now, it still needs to be tested and
likely edited though.