Corrected error handling in utils (fixes #6)