Use flags, and make JSON export optional