Make TransactionSet more functional

This modifies initialize and add_record to not modify internal variables, but rebind and return a new TransactionSet when adding a record.