Move library code to lib/ tree