Fix a bug in nucleotide count; Minor refactoring