MANY BUGFIXES (+ new tests)