Fixed a bug in the `dump()` function and also optimized its operation.