cleanup: error handling; debug print