Switched to sequelize as ORM and restructured code.