bugfix and robustness improvement