Lots of small cleanups. Added tests for pool.py