perf improvements for issue #88