Centralize code
Again some refactoring