Robustify stack-size calculation