Final refactor for better 404 handling