Fixed a few null references and improved 404 handling.