Move keydir code to its own file

Cleaner separation between NIF code and pure keydir code.
Also hooked up nifs and Erlang layer to new keydir interface.
It should compile cleanly now, without warnings.