Simplify script stats handling

This also fixes a small bug where forwarded script stats aren't
handled properly.
More debug logging around scripts