Cleanup and add JSON export