Fix result handling and logging