Added statistics, output pdf
Starting to move to subroutines