One order of magnitude faster by not constantly parsing haplotype file and recalculating MAF. Instead previously calculated MAF values are kept in a dictionary and a O(1) lookup is performed. The dictionary does not significantly increase the memory usage. The size of the dictionary is kept small by deleting MAF values of SNP positions, which have been looped over.