restructure the project code, move some code into lib dir