Cleaned up implementation of BioGram