Fixed some critical errors with analysis of avg case