Lot of refactoring, tests added, bugs fixed.
Cp
Cp