some modifications (small ones) to avoid errors found while running on the real data