Various fixes to get all tests pass