TODO: modify task API and make sure all functions there can take thunks instead of tasks as arguments.
We need more testing and performance testing. We also need to compare serializer and compacted_region.