robustify memory handling