Fixed KMG bug