simpler and faster unfold function

Simpler and faster. My tests on average and big file (4336 entries) show ~20% perf improvements).