Initial, quite fragile, implementation