Code robustness tweaks