fix up to pass existing tests, very ugly but working.