Massive refactoring

Actually not so refactoring as development evolution.