Update to n-gram code based on last weeks discussions