Log everything as json
Fix handling of flags