Recoded a bunch, moved even more, neatened up. Some testing done...