Make global variables local

I modified the compute_stats sub, so it won't modify global variables.