P07

Fixed algorithms.
Created PoolFunctions.h for calculations that can be unit tested.
Tried refactoring a little bit.