the casting as dict here and on line 504 doesn't seem worth it, just define it as a dict?