Implementation fixes to pass the tests