lots of tiny fixes, failing test cases
restrict fix, does not work for all cases