Updated for CGApplicationLibrary insertion. Lend to friends needs some more work