Some refactoring made