refactor pooling for it can be toggled with a flag to compare performance, see #39