Handle patching of ended_at
Fix timestamp issues + use transactions