Updated so DEBUG mode works with both SANDBOX and LIVE servers