Refactoring the library and some documentation