Copied implementation files from Gift ; most code can most likely be reused.