Fixed DB query for trips by splitting it into a query for real trips and another for produced trips; made run_chi_square() and compare_all() more flexible by letting them take a <statistic> as an argument; refined main() for testing.