Two problems in UpdateMembershipRecord script:
1. The membership object was not defined - and so the membership_log inserts failed.
2. When a reminder was sent, the membership.reminder_date was set to 0000-00-00 instead of NULL. This causes reminders to be sent for every run of the script once they are sent the first time (0000-00-00 is always < today).