Add error handling & stale_mate check