Alan

alan's few changes plus alan/alex's much bigger changes