Make a new Cocoa-friendly function and use it.
Get rid of the unused deprecated functions.