This version is for testing only - it has a bug and seg faults.