Added length checks for several list-based entities in to_dict