Refactored pooling system

This pretty much adds functionality described in #245