Fix calls to Mavericks only APIs
Rewrite some internals for key exchange