Reorganize code

Use more OO approach. Address edge cases like service modification.
Update tests