General improvement of organization and OO design of the code