Add safeguards against undefined maps