several improvements (not yet tested in the wild)