Complete rework. Now based on JSON.