Improved error handling and printout prettification.