Better error handling for maps