Move main file into lib