Do refactoring: get ready to make it as a library.