Make tests pass, new ability to add metadata to customers

Also includes patches from two other GitHub forks which don't seem to have been merged yet.