added sandbox mode, refactored lifecycle events (all api calls are now done on flush)