Refactor app.js into lib dir.