--debug
Updated to use the current RP API
No longer assuming "api" is global.
--debug
Waiting for callbacks to reduce crashes