Fixed minor calculation bug
Got rid of hard-coded maximum number of samples