Better checking for key dirs

Resolves the last bit of #298.