move save routine below tx reply to avoid delays
converting PSP from objective C to C
Merge branch 'master' into wd