Add get_stack_at method and use it.