fix entity scrubbing, returns JSON by default, debug flag for console testing