Initial code moved from xor repo.