Tests now pass.

Some fundamental eerrors still not fixed.