The current scale identification algorithm is pretty good but misses a lot of cues. Here are some ideas to enhance it:
Look not only at the frequency of the root, but the frequency of the fifth, to help establish the tonal center. The fifth should be, roughly, the second-most common note.
Look for melodic half-steps. In a major scale, for instance, 7th to root and 4th to 3rd are common transitions.
The current scale identification algorithm is pretty good but misses a lot of cues. Here are some ideas to enhance it: