Added check to template to ensure main #markup was set before adjusting it for 404 or 403 responses.