Improved 404 handling and memory management.