improved modularity; better comments; started statistical analysis