Small fixes to improve robustness.