Various fixes, all tests pass at this point. This should make the transition to sxql about 20% easier