Offload stack calculation to a new thread to avoid UI blocking (needs refactoring).