Pooling

work in progress, probably some bugs to find and fix