Massive refactoring
it's working