Refactoring and shaping the lib