Added statistics gathering
Added work with command line arguments
Fixed some bugs