Add more debug (error handling) code