Restructuring the code as a library
Adapted examples to the new structure