Some refactorings of the implementation code