Put all the code to the library. Started to add documentation.