Added more detailed per-thread stats; fixed ratio bug; integrated sanity tests with command line interface