Adapt main.js and db.js to work properly