Content handling. Improved debug messages and error handling.