Move app code into lib