Add better error tracking