several fixes, it passes some tests now