Cleanup formatting and exception types
Handle nested maps correctly in map_keys