few fixes to to_dataframe, seems to basically work