Various bug fixes (now 17 tests fails, it is 11 in trunk)