massive refactoring for cleaner usage