minor improvements for robustness